<{include file="section/admin/header2.tpl"}>


    	<h2 class="title01"><span>设置<{$keyword_name}></span></h2>
        <div class="line1"></div>
		<div class="boxform">
			<form action="/keyword/set" method="post" name="frm" id="frm">
			<input type="hidden" name="keyword_type" id="keyword_type" value="<{$keyword_type_name}>">
			<input type="hidden" name="limit_count_max" id="limit_count_max" value="<{$limit_count_max}>">
			<input type="hidden" name="limit_count_min" id="limit_count_min" value="<{$limit_count_min}>">
			<input type="hidden" name="limit_length_max" id="limit_length_max" value="<{$limit_length_max}>">
			<input type="hidden" name="limit_length_min" id="limit_length_min" value="<{$limit_length_min}>">
            <ul class="clear">
            <li class="i1"><span class="red">*</span> 开放城市：</li>
            <li><span style="width:100px;">
                <select name="city" id="city" onchange="change_city(this.value);">
					<{foreach from=$cities item=item  key=key}>
						<option <{if $current_city==$key}>selected<{/if}> value="<{$key}>"><{$item.name}></option>
					<{/foreach}>
            	</select>
            </span></li>
            </ul>
            
            <ul class="clear">            
            <li class="i1"><span class="red">*</span> 热门关键词：</li>
            <li><span style="width:100px;">
				<textarea name="keywords" id="keywords" class="in2" onblur="this.className='in2'" onfocus="this.className='in1'" rows="10" cols="45"><{$str_keywords}></textarea>
				</span></li>
            </ul>
            
            <ul class="clear">
            <li class="i1"><span class="red">*</span> 格式说明：</li>
            <li><span class="in">
				例如： 家居,沙发垫,茶几   注意：中间用英文逗号,隔开。
				<br>关键词个数最多<{$limit_count_max}>个，最少<{$limit_count_min}>个；
				单个关键词长度最长<{$limit_length_max}>个字符或汉字，最短<{$limit_length_min}>个字符或汉字
				</span></li>
            </ul>

			<div class="line margin25"></div>
            <ul class="clear">
            </ul>

			<ul class="clear">
            <li class="i1">&nbsp;</li>
            <li>
            	<input type="submit" class="btn04" value="确　定"/>　<input type="reset" class="btn04" value="重　置" />
            </li>
            </ul>
			</form>
        </div>
        

<script type="text/javascript">

<{if $smarty.get.flag}>
$(function(){
	var flag=<{$smarty.get.flag}>;
	if (parseInt(flag,10)==1)
		alert("设置关键词成功！");
	else if (parseInt(flag,10)==2)
		alert("设置关键词失败！");
})
<{/if}>
var frm = document.getElementById('frm');
frm.onsubmit = function ()
{	
	//单词不能超过6个
	var limit_count_max = document.getElementById("limit_count_max").value;
	var limit_count_min = document.getElementById("limit_count_min").value;
	var limit_length_max = document.getElementById("limit_length_max").value;
	var limit_length_min = document.getElementById("limit_length_min").value;

	var str=document.getElementById("keywords").value;
	var str_arr	= str.split(',');
	if(str=='')
	{
		alert("请填写热门关键词！");
		document.getElementById("keywords").focus();
		return false;
	}
	
	if(limit_count_max !='' && parseInt(limit_count_max,10) > 0 && str_arr.length > parseInt(limit_count_max,10))
	{
		alert("最多只能输入" + limit_count_max + "个关键词！");
		document.getElementById("keywords").focus();
		return false;
	}
	
	if(limit_count_min !='' && parseInt(limit_count_min,10) > 0 && str_arr.length < parseInt(limit_count_min,10))
	{
		alert("关键词个数不能少于" + limit_count_min + "个！");
		document.getElementById("keywords").focus();
		return false;
	}
	
    for( i=0 ; i<str_arr.length ; i++)
    {
    	if(limit_length_min !='' && parseInt(limit_length_min,10) > 0 && str_arr[i].length < parseInt(limit_length_min,10))
    	{
    		alert("关键词：" + str_arr[i] + "的长度不能小于" + limit_length_min + "个字符");
		    document.getElementById("keywords").focus();
			return false;
    	}
    	if(limit_length_max !='' && parseInt(limit_length_max,10) > 0 && str_arr[i].length > parseInt(limit_length_max,10))
    	{
    		alert("关键词：" + str_arr[i] + "的长度不能大于" + limit_length_max + "个字符");
		    document.getElementById("keywords").focus();
			return false;
    	}
    }
	return true;
}

function change_city(city_id)
{
   var keyword_type= document.getElementById("keyword_type").value;
   var url = "/keyword/index/"+keyword_type+"?city="+city_id;
   window.location = url;
}
</script>
<{include file="section/admin/footer2.tpl"}>
